package com.project.order.service;

import com.project.common.RespResult;
import com.project.order.feign.AccountFeign;
import com.project.order.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: seata-at
 * @description: 订单业务处理
 * @author: mml
 * @create: 2023/12/19
 */
@Service
public class OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    AccountFeign accountFeign;

    public boolean createOrder(String account, String projectId, Integer count) {
        RespResult result = accountFeign.deduct(account, (double) (count * 100));
        int flag = orderMapper.addOrder(account, projectId, count, (double) (count * 100));
        return flag == 1 & result.getCode() == 200 ? true : false;
    }

}
